---
layout: "default"
title: "count"
description: "Swift documentation for 'count': Return the number of elements in x."
keywords: "count,func,swift,documentation"
root: "/v1.2"
---

<div class="declaration" id="func-count-t_-collectiontype_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-count-t_-collectiontype_-t">func <wbr>count&lt;T : _CollectionType&gt;(<wbr>_: T)</a>
        
<div class="comment collapse" id="comment-func-count-t_-collectiontype_-t"><div class="p">
    <p>Return the number of elements in x.</p>

<p>O(1) if T.Index is RandomAccessIndexType; O(N) otherwise.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func count&lt;T : _CollectionType&gt;(x: T) -&gt; T.Index.Distance</code>
    
    
</div></div>
</div>
